package com.maxlen.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maxlen.common.utils.*;
import com.maxlen.coupon.dao.SeckillSessionTimeDao;
import com.maxlen.coupon.entity.CouponHistoryEntity;
import com.maxlen.coupon.entity.SeckillSessionTimeEntity;
import com.maxlen.coupon.service.SeckillSessionTimeService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("seckillSessionTimeService")
public class SeckillSessionTimeServiceImpl extends ServiceImpl<SeckillSessionTimeDao, SeckillSessionTimeEntity> implements SeckillSessionTimeService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        LambdaQueryWrapper<SeckillSessionTimeEntity> wrapper = new LambdaQueryWrapper<>();
        String key = params.get(Constant.KEY) == null ? null : params.get(Constant.KEY).toString();
        if(org.springframework.util.StringUtils.hasText(key)) {
            wrapper.like(SeckillSessionTimeEntity::getId, key);
        }

        IPage<SeckillSessionTimeEntity> page = this.page(
                new Query<SeckillSessionTimeEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }


}
